<?php
/************************
 *  Codenova.pl Project
 *  Created by: Kamil Mrzygłód
 *
 *  (c) 2013 by Codenova.pl
 *  All Right Reserved
 ***********************/

namespace Gotcha\App\Extensions;

// Gotcha cultures class

use Gotcha\App\Types\String;

final class GotchaCulturesExtension extends GotchaFileSystemExtension {
    static public function getTranslation(String $translation_id) {
        // Get current culture
        $current_application_culture = (string)parent::xmlFileHandler(new String('\App\Config\config.xml'), new String('defaultculture'));

        // Make sure culture file exists
        if (parent::CheckFileExistence(new String($current_application_culture.'.xml'), new String('App/Cultures/')) === true) {
            // If file exists we can load a translation connected with 
			// given id
			return parent::processCultureFile($translation_id, new String('\App\Cultures\\'.$current_application_culture.'.xml'));
        } else {
            GotchaLogsExtension::createNewLogEntry(new String('Plik kultury %s nie istnieje'), new String($current_application_culture.'.xml'));
            GotchaErrorsExtension::throwError(new String('Plik kultury %s nie istnieje'), new String($current_application_culture.'.xml'));
            exit;
        }
    }
}